package com.mxpio.erp.common.plm.entity;

import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.system.entity.TreeAble;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PLM_PROJECT_PROBLEM_SORT")
@Schema(description="问题分类")
public class ProjectProblemSort extends BaseEntity implements TreeAble<ProjectProblemSort> {

    private static final long serialVersionUID=1L;

    @Id
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "问题分类编码")
    @Column(name = "PROBLEM_CODE_", updatable = false)
    private String problemCode;

    @Column(name = "PROBLEM_NAME_")
    @Schema(description = "问题分类名称")
    private String problemName;

//    @Column(name="PROBLEM_TYPE_")
//    @Schema(description = "问题类型")
//    @Dict(dicCode = "ERP_PLM_PROJECT_PROBLEM_TYPE")
//    private String problemType;

    @Column(name = "PRO_TYPE_")
    @Schema(description = "项目类型")
    @Dict(dicCode = "ERP_PROJECT_INFO_PRO_TYPE")
    private String proType;

    @Column(name = "PARENT_CODE_")
    @Schema(description = "父级问题分类编码")
    private String parentCode;

//    @Column(name = "DESCRIPTION_")
//    @Schema(description = "描述")
//    private String description;

    @Transient
    private List<ProjectProblemSort> children;
    @Override
    public List<ProjectProblemSort> getTreeChildren() {
        return children;
    }
    @Override
    public String getCurrentNodeKey() {
        return problemCode;
    }

    @Override
    public String getParentNodeKey() {
        return parentCode;
    }

    @Override
    public void setTreeChildren(List<ProjectProblemSort> children) {
        this.children = children;
    }
}
